package com.health.ts.controller.sysmanage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.health.ts.constant.ApiResult;
import com.health.ts.constant.FrontPage;
import com.health.ts.constant.ValidGroup;
import com.health.ts.controller.BaseController;
import com.health.ts.entity.sysmanage.SysHospital;
import com.health.ts.service.sysmanage.SysHospitalService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 基础信息维护-医院管理
 * @author Administrator
 */
@Api(value = "基础信息维护-医院管理", tags = {"基础信息维护-医院管理"})
@RestController
@RequestMapping(value = "/api/baseInfo",produces= BaseController.JSON_UTF8)
public class HospitalController extends BaseController{
	
	/**
	 * 医院信息服务
	 */
	@Autowired
	SysHospitalService sysHospitalService;
	
	/**
	 * 医院分页列表
	 * @param page
	 * @return
	 */
	@ApiOperation(value = "医院分页列表", notes = "医院分页列表")
	@RequestMapping(value = "/hospitalPager",method=RequestMethod.GET)
	public ApiResult listHospitalPager(FrontPage page) {
		return ApiResult.success(sysHospitalService.selectHospitalPage(page));
	}
	
	/**
	 * 查询医院列表(不带分页)
	 * @return
	 */
	@ApiOperation(value = "查询医院列表(不带分页)", notes = "查询医院列表(不带分页)")
	@RequestMapping(value = "/hospitals",method=RequestMethod.GET)
	public ApiResult listHospital() {
		return ApiResult.success(sysHospitalService.listHospital());
	}
	
	/**
	 * 获取单个医院
	 * @param id
	 * @return
	 */
	@ApiOperation(value = "获取单个医院", notes = "获取单个医院")
	@RequestMapping(value="/hospital/{hospitalid}", method=RequestMethod.GET)
	public ApiResult selectHospital(@PathVariable String hospitalid) {
		return ApiResult.success(sysHospitalService.selectHospital(hospitalid));
	}
	
	/**
	 * 医院信息新增
	 * @param hospital
	 * @return
	 */
	@ApiOperation(value = "医院信息新增", notes = "医院信息新增")
	@RequestMapping(value="/hospital", method=RequestMethod.POST)
	public ApiResult addHospital(@RequestBody @Validated({ValidGroup.Crud.Create.class}) SysHospital hospital) {
		sysHospitalService.addHospital(hospital);
		return ApiResult.success();
	}
	
	/**
	 * 医院信息修改
	 * @param hospital
	 * @return
	 */
	@ApiOperation(value = "医院信息修改", notes = "医院信息修改")
	@RequestMapping(value="/hospital/{hospitalid}", method=RequestMethod.PUT)
	public ApiResult updateHospital(@PathVariable String hospitalid,@RequestBody @Validated({ValidGroup.Crud.Update.class}) SysHospital hospital) {
		sysHospitalService.updateHospital(hospitalid, hospital);
		return ApiResult.success();
	}
	
	/**
	 * 删除医院
	 * @param id
	 * @return
	 */
	@ApiOperation(value = "删除医院", notes = "删除医院")
	@RequestMapping(value="/hospital/{hospitalid}", method=RequestMethod.DELETE)
	public ApiResult deleteHospital(@PathVariable String hospitalid) {
		sysHospitalService.deleteHospital(hospitalid);
		return ApiResult.success();
	}
}
